<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="/benchmark/js/jquery.min.js"></script>
<script type="text/javascript" src="/benchmark/js/js.cookie.js"></script>
<title>BenchmarkTest00158</title>
</head>
<body>
<form action="/benchmark/cmdi-00/BenchmarkTest00158"  method="POST" id="FormBenchmarkTest00158">
    <div><label>Please explain your answer:</label></div>
    <br/>
	<div><textarea rows="4" cols="50" id="BenchmarkTest00158Area" name="BenchmarkTest00158Area"></textarea></div>
	<div><label>Any additional note for the reviewer:</label></div>
	<div><input type="text" id="answer" name="answer"></input></div>
    <br/>
    <div><label>An AJAX request will be sent with a header named BenchmarkTest00158 and value:</label> <input type="text" id="BenchmarkTest00158" name="BenchmarkTest00158" value="ECHOOO" class="safe"></input></div>

	<div><input type="button" id="login-btn" value="Login" onclick="submitForm()" /></div>
</form>
<div id="ajax-form-msg1"><pre><code class="prettyprint" id="code"></code></pre></div>
<script>
$('.safe').keypress(function (e) {
  if (e.which == 13) {
    submitForm();
    return false;
  }
});

function submitForm() {
    var formData = $("#FormBenchmarkTest00158").serialize();
    var URL = $("#FormBenchmarkTest00158").attr("action");
    var text = $("#FormBenchmarkTest00158 input[id=BenchmarkTest00158]").val();
    
    var xhr = new XMLHttpRequest();
    xhr.open("POST", URL, true);

    xhr.setRequestHeader('BenchmarkTest00158', text );

    xhr.onreadystatechange = function () {
        if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
            $("#code").html(xhr.responseText);
        }else{
        	$("#code").html("Error " + xhr.status + " ocurred.");
        }
    }
    xhr.send(formData);
}

function escapeRegExp(str) {
    return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

String.prototype.decodeEscapeSequence = function() {
    var txt = replaceAll(this,";","");
    txt = replaceAll(txt,"&#","\\");
    return txt.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
        return String.fromCharCode(parseInt(arguments[1], 16));
    });
};
</script>
</body>
</html>
